/*
 * ImageMagic v0.6
 * enix@foxmail.com
 * Copyright 2012 http://www.sinreweb.com/im/
 */
!
function(b, c) {
    var a = function() {};
    a.prototype = {
        request: function(i, u) {
            var d = (i.method).toUpperCase(),
            e = i.url,
            s = i.callback,
            h = i.postVars || null,
            j = i.timeout || 0,
            g = i.async || true,
            t = this,
            f;
            t.ajax = t.createXhr(),
            t.ajax.onreadystatechange = function() {
                switch (t.ajax.readyState) {
                case 1:
                    if (j) {
                        f = setTimeout(function() {
                            if (t.ajax.readyStat == 1) {
                                t.ajax.abort()
                            }
                        },
                        j);
                        clearTimeout(f)
                    }
                    s.loading ? s.loading.call(this, f) : null;
                    break;
                case 2:
                    s.loaded ? s.loaded.call(this, f) : null;
                    break;
                case 3:
                    s.interactive ? s.interactive.call(this, f) : null;
                    break;
                case 4:
                    /200|304/.test(t.ajax.status) ? s.success(t.ajax.responseText, t.ajax.responseXML) : {};
                    break
                }
            };
            t.ajax.open(d, e, g);
            if (d !== "POST") {
                h = null
            }
            t.ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            t.ajax.send(h);
            typeof u === "function" && u()
        },
        abortAjax: function() {
            this.ajax.abort()
        },
        createXhr: function() {
            var i = [function() {
                return new XMLHttpRequest()
            },
            function() {
                return new ActiveXObject("Msxml2.XMLHTTP")
            },
            function() {
                return new ActiveXObject("Mircosoft.XMLHTTP")
            }];
            for (var j = 0,
            d = i.length; j < d; j++) {
                try {
                    i[j]()
                } catch(k) {
                    continue
                }
                this.createXhr = i;
                return i[j]()
            }
            throw new Error("This browser could not create Ajax Object")
        },
        getJson: function(d) {
            this.temp = new a();
            this.temp.request(d);
            return parse = function(e) {
                if (!/^[\],:{}\s]*$/.test(e.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
                    return null
                }
                return b.JSON && b.JSON.parse ? b.JSON.parse(e) : (new Function("return " + e))()
            }
        }
    };
    imageMagic.tk.ajax || (imageMagic.tk.ajax = a)
} (window);